These are just some of the routines I use ** CONSTANTLY ** in VB3.
The code is FreeWare, i.e. I expect no payment, 'cos I reckon they
should have been included in VB anyway.
They've been fairly well tested, but as usual, use them at your
own risk.
Here's a quick description:
Sub ExitIfAlreadyRunning()
This checks if the current application is already running, and switches to it
if it is. It also exits the current instance in this case, and doesn't return.
I usually make it the first call in Sub Main.
Function FormFloat (FloatForm As Form, Floating%) As Integer
Makes a form "float" - i.e. Always on top, when Floating% = true. Switches
back to normal when Floating% = false. Returns the return code from
SetWindowPos().
The ProfileString functions just encapsulate the API functions. They also
use App.Title if ApplicationName = "". The Get* functions also remove the
trailing null chars (chr(0)) from the string.
For other data types, I convert to-from a string myself & use these.
Function GetPrivateProfileString (ByVal ApplicationName As String, KeyName As String, default As String, Size As Integer, FileName As String) As String
Function GetProfileString (ByVal ApplicationName As String, KeyName As String, default As String, Size As Integer) As String
Function WritePrivateProfileString (ByVal ApplicationName As String, KeyName As String, Value As String, FileName As String) As Integer
Function WriteProfileString (ByVal ApplicationName As String, KeyName As String, Value As String) As Integer
The following functions Save / Restore a forms position to / from WIN.INI.
The AppName parameter specifies the section - it will use App.Title if this
is blank. You could also modify it to save to another INI file.
Function SaveWindowPos (AppForm As Form, AppName As String) As Integer
Function RestoreWindowPos (AppForm As Form, AppName As String, Flags As Integer) As Integer
NB: The flags are defined in the [declarations] section, and allow you to
"partially restore" the position. One use is to ensure that the width & height
aren't restored - use WPR_LEFTTOP | WPR_STATE for this.
I usually call RestoreWindowPos() after loading the form, but before I Show
it, so the user doesn't see the move.
The *Sound* functions allow you to play sounds as defined in the WIN.INI
[Sounds] section. Note that you are not limited to the ones already there -
you can define your own, pointing to your own .WAV files.
NB: PlaySound(x) is equivalent to PlaySoundExt(x, SND_ASYNC)
Function PlaySound (SoundName As String)
Function PlaySoundExt (SoundName As String, Flags As Integer)